<template>
  <div class="third">
    <el-select
      v-model="formData.outsideType"
      style="margin-right: 10px"
      :disabled="formData.pointPlace !== 4"
      class="form-input-large"
      placeholder="请选择第三方平台"
      @change="handleSelect"
    >
      <el-option
        v-for="item in outsideType"
        :key="item.value"
        :label="item.label"
        :value="item.value"
      >
      </el-option>
    </el-select>
    <el-input
      v-if="formData.outsideType"
      class="form-input-large"
      style="margin-left: 5px"
      placeholder="请输入指向路径"
      @input="urlChange"
      v-model="formData.iconThreePoint"
    ></el-input>
  </div>
</template>

<script>
import { OUT_SIDE_TYPE } from '@/enum/index'
export default {
  props: {
    value: Object,
    pointPlace: Number
  },
  computed: {
    formData: {
      get() {
        return this.value
      },
      set(val) {
        return val
      }
    }
  },
  data() {
    return {
      outsideType: OUT_SIDE_TYPE
    }
  },
  methods: {
    //只能输入英文和特殊字符
    urlChange(val) {
      val = val.trim()
      this.formData.iconThreePoint = val.replace(/^[\u4e00-\u9fa5]+$/, '')
      this.$emit('input', this.value)
    },
    handleSelect() {
      this.formData.iconThreePoint = ''
      this.$emit('input', this.value)
    }
  }
}
</script>

<style>
.third {
  display: inline-block;
}
</style>
